package cn.edu.sjtu.stap.util;

import java.util.*;

import org.aspectj.org.eclipse.jdt.internal.compiler.ast.*;

public class AstArray {
    public static AstArray instance = null;

    public static AstArray getInstance() {
        if (instance == null) {
            instance = new AstArray();
        }
        return instance;
    }

    private List<CompilationUnitDeclaration> asts = new LinkedList<CompilationUnitDeclaration>();

    public void addCompilationUnitDeclaration(CompilationUnitDeclaration unit) {
        asts.add(unit);
    }

    public Iterator<CompilationUnitDeclaration> iterator() {
        return asts.iterator();
    }

    public void tidyUp() {
        Iterator<CompilationUnitDeclaration> i = this.iterator();
        while (i.hasNext()) {
            CompilationUnitDeclaration u = i.next();
            u.cleanUp();
            i.remove();
        }
    }
}
